package com.lythen.test.geo.es.entity;

import cn.hutool.core.lang.UUID;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.geostar.gd.one.common.spring.es.annotation.IndexPattern;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.*;
import org.springframework.data.elasticsearch.core.geo.GeoJson;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import java.util.Date;

/**
 * <h3>geo-elasticsearch</h3>
 * <p></p>
 *
 * @author : lythen
 * @date : 2022-07-14 23:03
 **/
@Data
@Document(indexName = "geo-data-#{T(java.time.LocalDate).now().toString()}",createIndex = false)
@Setting(replicas = 0,refreshInterval = "5s")
@IndexPattern("geo-data*")
public class GeoDataEntity {

    String id = UUID.fastUUID().toString();

    @Field(value = "@timestamp",store = true,type = FieldType.Date)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    Date date = new Date();

    int[] acroutes;

    int adcode;

    @GeoPointField
    GeoPoint center;

    @GeoPointField
    GeoPoint centroid;

    int childrenNum;

    @GeoShapeField
    GeoJson geometry;

    String level;
    String name;
    @DynamicMapping
    ParentArea parent;
    int subFeatureIndex;

}
